home *** CD-ROM | disk | FTP | other *** search
/ The Essential Home & Business Collection / The Essential Home & Business Collection.iso / 27 / 3 / 5 / HP22D5.ZIP / EXTERN / SETSCR.C < prev    next >
Text File  |  1991-04-16  |  2KB  |  95 lines

  1. #include "extern.h"        /* Extensions need these! */
  2. #include "io.h"
  3.  
  4. /*
  5. ** This routine reads a .BSV file and replaces the page picture layer with
  6. ** it.
  7. **
  8. ** To call this function from HyperPAD:
  9. **
  10. **    put importBSV("pic1.bsv") into rc;
  11. **    if rc is "error" then
  12. **      answer "There was an error importing the picture." with "Ok";
  13. */
  14. import(int NumArgs,HANDLE hFileName)
  15.  
  16. {
  17.     HANDLE hPic;
  18.     int handle = -1;
  19.     PTR rc;
  20.  
  21.     if (NumArgs != 1) goto bad;
  22.  
  23.     handle = open(deref(hFileName),READ);
  24.     if (handle == -1) goto bad;
  25.  
  26.     hPic = NewHandle(4000);
  27.     if (!hPic) {
  28. bad:
  29.         rc = "error";
  30. ok:
  31.         if (handle != -1) close(handle);
  32.         ReturnValue(stoh(rc));
  33.         return(STOP);
  34.     }
  35.  
  36.     read(handle,deref(hPic),7);    /* read first 7 bytes */
  37.  
  38.     read(handle,deref(hPic),4000);    /* read the picture */
  39.  
  40.     SetScreen(    TRUE,        /* set the page's picture */
  41.             1,1,80,25,    /* rectangle to set */
  42.             deref(hPic));    /* picture data */
  43.  
  44.     FreeHandle(hPic);
  45.  
  46.     rc = "";
  47.     goto ok;
  48. }
  49.  
  50. /*
  51. ** This routine clears the picture layer of the current page.
  52. **
  53. ** To call fro HyperPAD:
  54. **
  55. **    clearScreen;
  56. */
  57. clear()
  58.  
  59. {
  60.     HANDLE hPic;
  61.     PTR p;
  62.     int i;
  63.  
  64.     hPic = NewHandle(4000);
  65.     if (!hPic) return(STOP);
  66.  
  67.     for (i=0,p=deref(hPic);i<2000;i++) {
  68.         *p++ = 0;    /* character */
  69.         *p++ = 7;    /* attribute */
  70.     }
  71.  
  72.     SetScreen(TRUE,1,1,80,25,deref(hPic));
  73.  
  74.     FreeHandle(hPic);
  75.  
  76.     return(STOP);
  77. }
  78.  
  79. POOL pascal Pool[] = {
  80.     {    "importBSV",
  81.         import,
  82.         0,
  83.         FUNCTION},
  84.  
  85.     {    "clearScreen",
  86.         clear,
  87.         0,
  88.         HANDLER},
  89.  
  90.     {    NULL,
  91.         NULL,
  92.         0,
  93.         0}    };
  94.  
  95.